package lingnan.cn.edu.User;

import java.util.ArrayList;
import java.util.List;

import lingnan.cn.edu.util.StringUtil;

public class Staffinf {
	private int staffSuper;
	private String staffName,password;
	public int getStaffSuper() {
		return staffSuper;
	}
	public void setStaffSuper(int staffSuper) {
		this.staffSuper = staffSuper;
	}
	public String getStaffName() {
		return staffName;
	}
	public void setStaffName(String staffName) {
		this.staffName = staffName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	private StringBuilder columnPlaceholder = new StringBuilder();
	private StringBuilder paramPlaceholder = new StringBuilder();

	private List<Object> params= new ArrayList<Object>();
	
	public List<Object> getParams() {
		return params;
	}
	
	public StringBuilder getColumnPlaceholder() {
		return columnPlaceholder;
	}
	public StringBuilder getParamPlaceholder() {
		return paramPlaceholder;
	}
	
	@Override
	public String toString() {
		return "Staff [staffName=" + staffName + ", password=" + password + ", staffSuper=" + staffSuper + "]";
	}
	
public void dualDynamicSQL() {
		
		if(!StringUtil.isEmpty(staffName)) {
			columnPlaceholder.append("staffName").append(",");
			paramPlaceholder.append("?,");
			params.add(staffName);
		}
		
		if(!StringUtil.isEmpty(password)) {			
			columnPlaceholder.append("password").append(",");
			paramPlaceholder.append("?,");
			params.add(password);
		}
		
		if(!StringUtil.isEmpty(staffSuper)) {
			columnPlaceholder.append("staffSuper").append(",");
			paramPlaceholder.append("?,");
			params.add(staffSuper);			
		}
		 
		int index = columnPlaceholder.lastIndexOf(",");
		if(index!=-1) {
			columnPlaceholder.deleteCharAt(index);
			paramPlaceholder.deleteCharAt(paramPlaceholder.lastIndexOf(","));
		}
 	}
}
